package com.my.zl.console.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.my.zl.common.dto.ReqDTO;
import com.my.zl.common.dto.ResDTO;
import com.my.zl.common.dto.advancedQuery.PageQueryDTO;
import com.my.zl.console.common.aop.LogAnnotation;
import com.my.zl.console.controller.base.BaseController;
import com.my.zl.console.entity.autocode.ZlValidation;
import com.my.zl.console.dto.autocode.validation.ReqValidationAddDTO;
import com.my.zl.console.dto.autocode.validation.ReqValidationDelDTO;
import com.my.zl.console.dto.autocode.validation.ReqValidationEditDTO;
import com.my.zl.console.dto.autocode.validation.ReqValidationQueryDTO;
import com.my.zl.console.dto.autocode.validation.ReqValidationDetailDTO;
import com.my.zl.console.dto.autocode.validation.ReqValidationStateDTO;
import com.my.zl.console.dto.autocode.validation.ResValidationAddDTO;
import com.my.zl.console.dto.autocode.validation.ResValidationDelDTO;
import com.my.zl.console.dto.autocode.validation.ResValidationEditDTO;
import com.my.zl.console.dto.autocode.validation.ResValidationQueryDTO;
import com.my.zl.console.dto.autocode.validation.ResValidationDetailDTO;
import com.my.zl.console.service.autocode.IValidationService;
import com.my.zl.console.dto.autocode.validation.ResValidationStateDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 校验规则
 * @author ZL
 */
@Api(value="校验规则",tags ="校验规则")
@RestController
@RequestMapping("/api/autocode/validation")
public class ValidationController extends BaseController {

    @Autowired
    private IValidationService validationService;
    
    /**
     * 查询
     */
    @ApiOperation(value="校验规则-查询")
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public ResDTO<ResValidationQueryDTO> listValidation(ReqValidationQueryDTO reqInfo,PageQueryDTO page) throws Exception{
        ResValidationQueryDTO data = validationService.queryValidationList(reqInfo,page);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="校验规则-详情")
    @RequestMapping(value="/detail", method = RequestMethod.GET)
    public ResDTO<ResValidationDetailDTO> detailValidation(ReqValidationDetailDTO reqInfo) throws Exception{
        ResValidationDetailDTO data = validationService.queryValidationDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="校验规则-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public ResDTO<ResValidationAddDTO> addValidation(@RequestBody ReqDTO<ReqValidationAddDTO> reqInfo) throws Exception{
        ResValidationAddDTO data = validationService.insertValidationInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="校验规则-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
    public ResDTO<ResValidationEditDTO> editValidation(@RequestBody ReqDTO<ReqValidationEditDTO> reqInfo) throws Exception{
        ResValidationEditDTO data = validationService.updateValidationInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="校验规则-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
    public ResDTO<ResValidationDelDTO> delValidation(@RequestBody ReqDTO<ReqValidationDelDTO> reqInfo) throws Exception{
        ResValidationDelDTO data = validationService.deleteValidationInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="校验规则-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
    public ResDTO<ResValidationStateDTO> stateValidation(@RequestBody ReqDTO<ReqValidationStateDTO> reqInfo) throws Exception{
        ResValidationStateDTO data = validationService.updateValidationState(reqInfo);
        return successDATA(data); 
    }
    
    
}